package com.example.vehicle.Entity;

import java.util.Arrays;

/**
 * @name: Key
 * @description: 密钥类，保存此次登录时获取的公钥证书、生成的对称密钥和Hmac密钥。
 * @author: Lulu Zhao
 **/
public class Key {

    String publicKey;
    byte[] KeySM4;
    byte[] KeyHmac;

    /**
     * @name: Key
     * @description: 无参构造函数。
     * @params: []
     * @return:
     * @author: Lulu Zhao
     */
    public Key() {
    }

    /**
     * @name: Key
     * @description: 有参构造函数。
     * @params: [publicKey, keySM4, keyHmac]
     * @return:
     * @author: Lulu Zhao
     */
    public Key(String publicKey, byte[] keySM4, byte[] keyHmac) {
        this.publicKey = publicKey;
        KeySM4 = keySM4;
        KeyHmac = keyHmac;
    }

    /**
     * @name: getPublicKey
     * @description: 获取RSU公钥。
     * @params: []
     * @return: java.lang.String
     * @author: Lulu Zhao
     */
    public String getPublicKey() {
        return publicKey;
    }

    /**
     * @name: setPublicKey
     * @description: 设置RSU公钥。
     * @params: [publicKey]
     * @return: void
     * @author: Lulu Zhao
     */
    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    /**
     * @name: getKeySM4
     * @description: 获取对称密钥。
     * @params: []
     * @return: byte[]
     * @author: Lulu Zhao
     */
    public byte[] getKeySM4() {
        return KeySM4;
    }

    /**
     * @name: setKeySM4
     * @description: 设置对称密钥。
     * @params: [keySM4]
     * @return: void
     * @author: Lulu Zhao
     */
    public void setKeySM4(byte[] keySM4) {
        KeySM4 = keySM4;
    }

    /**
     * @name: getKeyHmac
     * @description: 获取Hmac密钥。
     * @params: []
     * @return: byte[]
     * @author: Lulu Zhao
     */
    public byte[] getKeyHmac() {
        return KeyHmac;
    }

    /**
     * @name: setKeyHmac
     * @description: 设置Hmac密钥。
     * @params: [keyHmac]
     * @return: void
     * @author: Lulu Zhao
     */
    public void setKeyHmac(byte[] keyHmac) {
        KeyHmac = keyHmac;
    }

    /**
     * @name: toString
     * @description: toString方法。
     * @params: []
     * @return: java.lang.String
     * @author: Lulu Zhao
     */
    @Override
    public String toString() {
        return "Key{" +
                "publicKey='" + publicKey + '\'' +
                ", KeySM4=" + Arrays.toString(KeySM4) +
                ", KeyHmac=" + Arrays.toString(KeyHmac) +
                '}';
    }
}
